package com.example.qiehuanactivity;

import java.io.InputStream;

import com.example.android.navigationdrawerexample.R;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class strategy extends Activity {
	
	ImageView []image=new ImageView[8];
	ImageView []imageicon=new ImageView[7];
	int []imagesrc={R.drawable.u51_normal,R.drawable.u66_normal,R.drawable.u58_normal,R.drawable.u34_normal,R.drawable.u38_normal,R.drawable.u52_normal,R.drawable.u62_normal,R.drawable.u73_normal,R.drawable.u84_normal,R.drawable.u67_normal,R.drawable.u50_normal,R.drawable.u61_normal,R.drawable.u76_normal,R.drawable.u103_normal};
	int i;
	int click=-1;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sb5_lj);
		image[0]=(ImageView) findViewById(R.id.imageView12);
		image[1]=(ImageView) findViewById(R.id.imageView2);
		image[2]=(ImageView) findViewById(R.id.imageView5);
		image[3]=(ImageView) findViewById(R.id.imageView6);
		image[4]=(ImageView) findViewById(R.id.imageView7);
		image[5]=(ImageView) findViewById(R.id.imageView8);
		image[6]=(ImageView) findViewById(R.id.imageView9);
		image[7]=(ImageView) findViewById(R.id.imageView10);
		imageicon[0]=(ImageView) findViewById(R.id.imageView12);
		imageicon[1]=(ImageView) findViewById(R.id.imageView15);
		imageicon[2]=(ImageView) findViewById(R.id.imageView16);
		imageicon[3]=(ImageView) findViewById(R.id.imageView17);
		imageicon[4]=(ImageView) findViewById(R.id.imageView18);
		imageicon[5]=(ImageView) findViewById(R.id.imageView19);
		imageicon[6]=(ImageView) findViewById(R.id.imageView20);
		for(int j=0;j<6;j++)
		{
			BitmapFactory.Options opt ;
			InputStream is;
			Bitmap bit ;
			opt= new BitmapFactory.Options();
		       opt.inPreferredConfig = Bitmap.Config.RGB_565;
		       opt.inPurgeable = true;
		       opt.inInputShareable = true;
		        is= getResources().openRawResource(
						imagesrc[13]);
		        
		      bit = BitmapFactory.decodeStream(is, null, opt);
		       image[i+2].setImageBitmap(bit);
		       opt= new BitmapFactory.Options();
		       opt.inPreferredConfig = Bitmap.Config.RGB_565;
		       opt.inPurgeable = true;
		       opt.inInputShareable = true;
		        is= getResources().openRawResource(
						imagesrc[0]);
		        
		      bit = BitmapFactory.decodeStream(is, null, opt);
		       imageicon[i].setImageBitmap(bit);
		       
		       
		}
	//	final boolean [] click={false,false,false,false,false,false};
//		image[0].setOnClickListener(new Button.OnClickListener(){
//			public void onClick(View v) {
//				if(click==-1)
//				{
//				BitmapFactory.Options opt = new BitmapFactory.Options();
//			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
//			       opt.inPurgeable = true;
//			       opt.inInputShareable = true;
//			       InputStream is = getResources().openRawResource(
//							R.drawable.u34_normal);
//			       Bitmap bit = BitmapFactory.decodeStream(is, null, opt);
//			       img.setImageBitmap(bit);
//				}
//				else
//				{
//					
//				}
//			       
//			}
//		});
		
		
			image[2].setOnClickListener(new Button.OnClickListener(){
				public void onClick(View v) {
					BitmapFactory.Options opt ;
					InputStream is;
					Bitmap bit ;
					opt= new BitmapFactory.Options();
				       opt.inPreferredConfig = Bitmap.Config.RGB_565;
				       opt.inPurgeable = true;
				       opt.inInputShareable = true;
				        is= getResources().openRawResource(
								imagesrc[1]);
				        
				      bit = BitmapFactory.decodeStream(is, null, opt);
				       image[0].setImageBitmap(bit);
				       opt = new BitmapFactory.Options();
				       opt.inPreferredConfig = Bitmap.Config.RGB_565;
				       opt.inPurgeable = true;
				       opt.inInputShareable = true;
				       is = getResources().openRawResource(
								imagesrc[2]);
				       bit = BitmapFactory.decodeStream(is, null, opt);
				       ((ImageView) findViewById(R.id.imageView15)).setImageBitmap(bit);
						if(click!=-1)
						{
						       opt = new BitmapFactory.Options();
						       opt.inPreferredConfig = Bitmap.Config.RGB_565;
						       opt.inPurgeable = true;
						       opt.inInputShareable = true;
						       is = getResources().openRawResource(
										imagesrc[0]);
						       bit = BitmapFactory.decodeStream(is, null, opt);
						      imageicon[click-1].setImageBitmap(bit);
						      
						       
						}
						click=2;
					
				       
				}
			});
		
		
		image[3].setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				
				BitmapFactory.Options opt ;
				InputStream is;
				Bitmap bit ;
				opt= new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			        is= getResources().openRawResource(
							imagesrc[3]);
			        
			      bit = BitmapFactory.decodeStream(is, null, opt);
			       image[0].setImageBitmap(bit);
			       opt = new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			       is = getResources().openRawResource(
							imagesrc[4]);
			       bit = BitmapFactory.decodeStream(is, null, opt);
			       ((ImageView) findViewById(R.id.imageView16)).setImageBitmap(bit);
					if(click!=-1)
					{
					       opt = new BitmapFactory.Options();
					       opt.inPreferredConfig = Bitmap.Config.RGB_565;
					       opt.inPurgeable = true;
					       opt.inInputShareable = true;
					       is = getResources().openRawResource(
									imagesrc[0]);
					       bit = BitmapFactory.decodeStream(is, null, opt);
					       imageicon[click-1].setImageBitmap(bit);
					      
					       
					}
					click=3;
				
			       
			}
		});
		image[4].setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {

				BitmapFactory.Options opt ;
				InputStream is;
				Bitmap bit ;
				opt= new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			        is= getResources().openRawResource(
							imagesrc[5]);
			        
			      bit = BitmapFactory.decodeStream(is, null, opt);
			       image[0].setImageBitmap(bit);
			       opt = new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			       is = getResources().openRawResource(
							imagesrc[6]);
			       bit = BitmapFactory.decodeStream(is, null, opt);
			       ((ImageView) findViewById(R.id.imageView17)).setImageBitmap(bit);
					if(click!=-1)
					{
						opt= new BitmapFactory.Options();
					       opt.inPreferredConfig = Bitmap.Config.RGB_565;
					       opt.inPurgeable = true;
					       opt.inInputShareable = true;
					        is= getResources().openRawResource(
									imagesrc[0]);
					        
					      bit = BitmapFactory.decodeStream(is, null, opt);
					      imageicon[click-1].setImageBitmap(bit);
					      
					       
					}
					click=4;
				
			       
			}
		});
		image[5].setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {

				BitmapFactory.Options opt ;
				InputStream is;
				Bitmap bit ;
				opt= new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			        is= getResources().openRawResource(
							imagesrc[7]);
			        
			      bit = BitmapFactory.decodeStream(is, null, opt);
			       image[0].setImageBitmap(bit);
			       opt = new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			       is = getResources().openRawResource(
							imagesrc[8]);
			       bit = BitmapFactory.decodeStream(is, null, opt);
			       ((ImageView) findViewById(R.id.imageView18)).setImageBitmap(bit);
					if(click!=-1)
					{
					       opt = new BitmapFactory.Options();
					       opt.inPreferredConfig = Bitmap.Config.RGB_565;
					       opt.inPurgeable = true;
					       opt.inInputShareable = true;
					       is = getResources().openRawResource(
									imagesrc[0]);
					       bit = BitmapFactory.decodeStream(is, null, opt);
					       imageicon[click-1].setImageBitmap(bit);
					     
					       
					}
			    click=5;
			}
		});
		image[6].setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				BitmapFactory.Options opt ;
				InputStream is;
				Bitmap bit ;
				opt= new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			        is= getResources().openRawResource(
							imagesrc[9]);
			        
			      bit = BitmapFactory.decodeStream(is, null, opt);
			       image[0].setImageBitmap(bit);
			       opt = new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			       is = getResources().openRawResource(
							imagesrc[10]);
			       bit = BitmapFactory.decodeStream(is, null, opt);
			       ((ImageView) findViewById(R.id.imageView19)).setImageBitmap(bit);
					if(click!=-1)
					{
					       opt = new BitmapFactory.Options();
					       opt.inPreferredConfig = Bitmap.Config.RGB_565;
					       opt.inPurgeable = true;
					       opt.inInputShareable = true;
					       is = getResources().openRawResource(
									imagesrc[0]);
					       bit = BitmapFactory.decodeStream(is, null, opt);
					       imageicon[click-1].setImageBitmap(bit);
					     
					       
					}
					 click=6;
				
			       
			}
		});
		image[7].setOnClickListener(new Button.OnClickListener(){
			public void onClick(View v) {
				BitmapFactory.Options opt ;
				InputStream is;
				Bitmap bit ;
				opt= new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			        is= getResources().openRawResource(
							imagesrc[11]);
			        
			      bit = BitmapFactory.decodeStream(is, null, opt);
			       image[0].setImageBitmap(bit);
			       opt = new BitmapFactory.Options();
			       opt.inPreferredConfig = Bitmap.Config.RGB_565;
			       opt.inPurgeable = true;
			       opt.inInputShareable = true;
			       is = getResources().openRawResource(
							imagesrc[12]);
			       bit = BitmapFactory.decodeStream(is, null, opt);
			       ((ImageView) findViewById(R.id.imageView20)).setImageBitmap(bit);
					if(click!=-1)
					{
					       opt = new BitmapFactory.Options();
					       opt.inPreferredConfig = Bitmap.Config.RGB_565;
					       opt.inPurgeable = true;
					       opt.inInputShareable = true;
					       is = getResources().openRawResource(
									imagesrc[0]);
					       bit = BitmapFactory.decodeStream(is, null, opt);
					       imageicon[click-1].setImageBitmap(bit);
					     
					       
					}
					 click=7;
				
			       
			}
		});
	}
}
